package basic50.fortieth;

public class Basic33 {
    public static void main(String[] args) {
/*        题目：打印出杨辉三角形（要求打印出10行如下图）
        程序分析：
                1
               1 1
              1 2 1
             1 3 3 1
            1 4 6 4 1
           1 5 10 10 5 1
           */

        int n = 10;
        int[][] triangle = new int[n][n];
        for (int i = 1; i <= n; i++) {
            for (int j = 0; j < n-i; j++) {
                System.out.print(" ");
            }
            triangle[i-1][0] = 1;
            triangle[i-1][i-1] = 1;
            for (int j = 0; j < 1; j++) {
                System.out.print(triangle[i-1][j] + " ");
            }
            for (int j = 1; j < i; j++) {
                triangle[i-1][j] = triangle[i-2][j-1] + triangle[i-2][j];
                System.out.print(triangle[i-1][j] + " ");
            }
            System.out.println();
        }
    }
}
